<?php
  require("../config.php");
  
     

  $login_in=$_POST['login'] ;
  $password_in=$_POST['password'] ;
  $compte=$_POST['compte'];
  
  
  if($compte=="stagiaire") {
    $query = "SELECT 	idstagiaire, identifiant, motdepass FROM "; 
    $query .="stagiaire where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		  if($ligne=mysql_fetch_array($result)) {               
            
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte; 
			$_SESSION['idstagiaire'] =	$ligne['idstagiaire'];
       
			header('Location: ../Prive/Stagiaires/page_stagiare.php ');			
          }
		  else
		  header('Location: index.php?msg=" Login et/ou le mot de passe non valid   !!!"');    
		  
    } 
  }
  else if($compte=="societe"){
    $query = "SELECT identreprise,	 identifiant, motdepass FROM "; 
    $query .="entreprise where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		 if($ligne=mysql_fetch_array($result))
		{
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte;
			$_SESSION['identreprise'] =	$ligne['identreprise'];
			header('Location: ../Prive/Entreprises/page_societe.php '); 			
        }
		else
		header('Location: index.php?msg=" Login et/ou le mot de passe non valid  !!!"');    
  }
  }
  else if($compte=="owner"){
     $query = "SELECT 	idadmin, identifiant, motdepass FROM "; 
     $query .="admin where identifiant='$login_in' and motdepass='$password_in'";
	// echo "".$query;
    if($result = mysql_query($query)) 
	{
		if($ligne=mysql_fetch_array($result)) 
		 {
			session_start (); 
			$_SESSION['login'] =	$login_in  ;
			$_SESSION['ident'] =	$compte;
			$_SESSION['idmin'] =	$ligne['idmin'];
			header('Location:   page_admin.php ');		
         }
		else
		header('Location: index.php?msg=" Login et/ou le mot de passe non valid  !!!"');    
    } 
  
  }        
  else
  {      
    //retour vers le formulaire avec accompagne du message d'erreur 
    header('Location: index.php?msg=" Identifiez vous !!!"');      
  }   



?>